#include "namedpipe.hpp"
int main()
{
    // 以创建者的身份打开
    NamedPipe fifo(path, Creater);
    if (fifo.OpenforRead())
    {
        std::cout << "Server open fifopipe for read!" << std::endl;
        while (true)
        {
            std::string message;
            int n = fifo.ReadNamedPipe(&message);
            if (n > 0)
            {
                std::cout << "Client:" << message << std::endl;
            }
            else if (n == 0)
            {
                std::cout << "写端关闭了，读端也要关闭！" << std::endl;
                break;
            }
            else if (n < 0)
            {
                std::perror("read"); 
                break;
            }
        }
    }
    return 0;
}